class Post < ActiveRecord::Base

  before_create :generate_permalink
  
  validates_presence_of :title
  validates_presence_of :entry
  
  def generate_permalink
    self.permalink = self.title.downcase.gsub(/\s+/, '-').gsub(/[^a-zA-Z0-9-]+/, '')
  end

end
